package com.myself.storm_test;

import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;

public class WordCountBuilder {

	public WordCountBuilder(TopologyBuilder builder) {
	    builder.setSpout("spout", new RandomSentenceSpout(), 1);
	    builder.setBolt("split", new SplitSentenceBolt(), 2).shuffleGrouping("spout");
	    builder.setBolt("wordcount", new WordCountBolt(), 4).fieldsGrouping("split", new Fields("word"));
	    //线程1汇总输出
	    builder.setBolt("countresult", new WordCountBolt2(), 1).fieldsGrouping("wordcount", new Fields("word","count")).globalGrouping("spout","SUCCESS_STREAM");
	}
}
